package main.od;

import java.util.Arrays;
import java.util.Scanner;

public class RewardGroup {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        int max = Integer.parseInt(line);
        String[] s = scanner.nextLine().split(" ");
        int[] arr = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            arr[i] = Integer.parseInt(s[i]);
        }
        Arrays.sort(arr);
        System.out.println(get(max, arr));
    }
    public static int get(int max, int[] arr) {
        int num = 0;
        int i = 0;
        int j = arr.length - 1;
        while (j >= i) {
            if (Integer.valueOf(i).equals(j)) {
                num++;
                break;
            }
            if (arr[j] + arr[i] <= max) {
                num++;
                i++;
                j--;
            } else {
                j--;
                num++;
            }
        }
        return num;
    }

}
